package com.wc.算法基础课.C第三讲搜索与图论.Flood_Fill.画图;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/19 14:14
 * @description https://www.acwing.com/problem/content/3227/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 110;
    static char[][] g = new char[N][N];
    static int[] dx = new int[]{-1, 0, 1, 0};
    static int[] dy = new int[]{0, -1, 0, 1};
    static int m, n, q, op, x, y, x1, y1, x2, y2;
    static char c;

    public static void main(String[] args) {
        m = sc.nextInt();
        n = sc.nextInt();
        q = sc.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                g[i][j] = '.';
            }
        }
        while (q-- > 0) {
            op = sc.nextInt();
            if (op == 0) {
                y1 = sc.nextInt();
                x1 = sc.nextInt();
                y2 = sc.nextInt();
                x2 = sc.nextInt();
                // 在同一行
                if (x1 == x2) {
                    for (int i = Math.min(y1, y2); i <= Math.max(y1, y2); i++) {
                        if (g[x1][i] == '.' || g[x1][i] != '|' && g[x1][i] != '+') {
                            g[x1][i] = '-';
                        } else {
                            g[x1][i] = '+';
                        }
                    }
                } else {
                    for (int i = Math.min(x1, x2); i <= Math.max(x1, x2); i++) {
                        if (g[i][y1] == '.' || g[i][y1] != '-' && g[i][y1] != '+') {
                            g[i][y1] = '|';
                        } else {
                            g[i][y1] = '+';
                        }
                    }
                }
            } else {
                y = sc.nextInt();
                x = sc.nextInt();
                c = sc.next().toCharArray()[0];
                dfs(x, y, c);
            }
        }
        for (int i = n - 1; i >= 0; i--) {
            for (int j = 0; j < m; j++) {
                out.print(g[i][j]);
            }
            out.println();
        }
        out.flush();
    }

    static void dfs(int x, int y, char c) {
        g[x][y] = c;
        for (int i = 0; i < 4; i++) {
            int a = x + dx[i];
            int b = y + dy[i];
            if (a >= 0 && a < n && b >= 0 && b < m && g[a][b] != '|' && g[a][b] != '-' && g[a][b] != '+' && g[a][b] != c) {
                dfs(a, b, c);
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}